<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改盘点')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <input name="deptId"  type="hidden"  id="treeId"/>
    <div class="form-group">
        <div class="col-sm-8">
            <div class="input-group">
                <input name="deptName" onclick="selectDeptTree()" id="treeName" type="text" placeholder="请选择归属部门" class="form-control" required readonly="true">
                <span class="input-group-addon"><i class="fa fa-search"></i></span>
            </div>
        </div>
        <button type="button" class="btn btn-info" onclick="setStocktaking()">将所选门店下的商品设置为未盘商品</button>
    </div>

</div>
<div th:include="include::footer"></div>
<script type="text/javascript">
    var prefix = ctx + "system/tStocktaking";
    $("#form-tStocktaking-edit").validate({
        rules:{
            xxxx:{
                required:true,
            },
        },
        focusCleanup: true
    });

    function setStocktaking() {
        var deptId = $("#treeId").val();
        var data="deptId="+deptId;
        var config = {
            url: prefix + "/saveSetStocktaking",
            type: "post",
            dataType: "json",
            data: data,
            beforeSend: function () {
                // $.modal.loading("正在处理中，请稍后...");
                $.modal.disable();
            },
            success: function(result) {
                $.modal.alert("设置成功！", modal_status.SUCCESS);
            }
        };
        $.ajax(config)
    }

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-tStocktaking-edit').serialize());
        }
    }

    /*用户管理-修改-选择部门树*/
    function selectDeptTree() {
        var deptId = $.common.isEmpty($("#treeId").val()) ? "100" : $("#treeId").val();
        var url = ctx + "system/dept/selectDeptTree/" + deptId;
        var options = {
            title: '选择部门',
            width: "380",
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    }

    function doSubmit(index, layero){
        var tree = layero.find("iframe")[0].contentWindow.$._tree;
        if ($.tree.notAllowParents(tree)) {
            var body = layer.getChildFrame('body', index);
            $("#treeId").val(body.find('#treeId').val());
            $("#treeName").val(body.find('#treeName').val());
            layer.close(index);
        }
    }

</script>
</body>
</html>
